package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Vector;

public class GetAllSuppliers {

	Vector<Vector>  resTableSupp;
	
	public Vector<Vector> getSupp()
	{
		SQLConnection sc=new SQLConnection();
		
		
		try {

		PreparedStatement ps = sc.getConnection().prepareStatement("SELECT suppID,suppName,suppPhoneNo,suppPhoneNo2,suppCellNo,suppMail,suppFax,suppContactMen,suppZipCode,suppCity,suppHouse,suppStreet FROM  Supplier Where suppStatus='פעיל' ;");	

		ResultSet rs=ps.executeQuery();	

		ResultSetMetaData rsmd = rs.getMetaData();

		resTableSupp = new Vector<Vector>();
		
		 while(rs.next())
	        {   

			 Vector<String>  row = new Vector<String>();
	         for(int col = 1; col <= rsmd.getColumnCount(); col++) 
	         	{                      	                
	                int type = rsmd.getColumnType(col);
	                switch(type)
	                {
	                
	                    case Types.INTEGER :
	                        row.add(new Integer(rs.getInt(col)).toString());
	                        break;
	                        
	                    case Types.VARCHAR :
	                        row.add(rs.getString(col));
	                        break;
	                    case Types.DATE :
	                        row.add(rs.getDate(col).toString());
	                        break;    
	                }//switch
	         	}//for
	         resTableSupp.add(row);
	        }//while
		 ps.close();
		 rs.close();
		 sc.getConnection().close();
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return resTableSupp;
	}

}
	
	

